package com.atguigu.spzx.manager.service.Impl;

import com.atguigu.spyx.model.common.com.atguigu.spyx.model.entity.product.Brand;
import com.atguigu.spyx.model.common.com.atguigu.spyx.model.entity.product.CategoryBrand;
import com.atguigu.spyx.model.vo.system.CategoryBrandVo;
import com.atguigu.spzx.manager.mapper.CategoryBrandMapper;
import com.atguigu.spzx.manager.service.CategoryBrandService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author LT
 * @create 2023-11-09-10:14
 */
@Service
public class CategoryBrandServiceImpl implements CategoryBrandService {

    @Resource
    CategoryBrandMapper categoryBrandMapper;


    @Override
    public void deleteById(Long id) {
        categoryBrandMapper.deleteById(id);
    }

    @Override
    public void save(CategoryBrand categoryBrand) {
        categoryBrandMapper.save(categoryBrand);
    }

    @Override
    public CategoryBrand getById(Long id) {
        return categoryBrandMapper.getById(id);
    }

    @Override
    public void updateById(CategoryBrand categoryBrand) {
        categoryBrandMapper.updateById(categoryBrand);
    }

    @Override
    public PageInfo<CategoryBrandVo> page(Integer pageNum, Integer pageSize, CategoryBrand categoryBrand) {
        PageHelper.startPage(pageNum,pageSize);
        List<CategoryBrandVo> list = categoryBrandMapper.findByCondition(categoryBrand);
        PageInfo<CategoryBrandVo> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public List<Brand> findBrandByCategoryId(Long c3id) {
        return categoryBrandMapper.findBrandByCategoryId(c3id);
    }
}
